// pages/account/logistics/index.js
const app = getApp()

Page({

  /**
   * 页面的初始数据
   */
	data: {
		imgurl: app.urlimg,
		isFold: 'true',
		heads: [
			{ img: '/pages/icon/u213.png', express: '邮政快递包裹', digit: '9891261638109', phone: '11183', }
		],
		box: [],
		address: [
		],
		address_all: [],
		// 猜你喜欢列表
		like_lists: [],
	},
	//复制按钮
	copy_btn: function () {
		console.log('复制运单编号');
		var that = this;
		wx.setClipboardData({
			data: that.data.data.freight.delivery_code,
			success: function (res) {
				console.log(res);
				wx.getClipboardData({
					success: function (res) {
						console.log(res.data) // data
						//提示信息
						wx.showToast({
							title: '复制成功',
							icon: 'success',
							duration: 1000,
						})
					}
				})
			}
		})
	},
	//投诉物流
	complaints: function () {
		console.log("投诉物流");
	},
	// 查看物流信息
	flodFn: function (e) {
		console.log(e);
		var that = this;


		// 订单栏
		// var height_animation = wx.createAnimation({
		// 	duration: 200,
		// })
		// this.animation = height_animation
		// height_animation.rotate(270).step()
		// this.setData({
		// 	height_animation: height_animation.export()
		// })


		// 箭头旋转
		var animation = wx.createAnimation({
			duration: 200,
		})
		this.animation = animation;
		var address = [];
		if (that.data.data.freight !== false) {
			if (that.data.isFold) {
				address = that.data.data.freight.data;
				animation.rotate(270).step();
			} else {
				var address_all = that.data.data.freight.data;

				for (var i = 0; i < 3; i++) {
					address.push(address_all[i]);
				}
				animation.rotate(90).step();
			}

		}
		this.setData({
			arrow_animation: animation.export(),
			isFold: !that.data.isFold,
			address: address,
		})




	},
	// 进入商品详情
	click_goods: function (e) {
		console.log(e.currentTarget.id);
		var id = e.currentTarget.id;
		wx.redirectTo({
			url: '/pages/index/detail/index?id=' + id,
		})
	},
  /**
   * 生命周期函数--监听页面加载
   */
	onLoad: function (options) {
		// console.log(options.dataset.id); //产品id（好像是）
		// console.log(options.dataset.order_id); //订单号（好像是）
		var that = this;
		wx.request({
			url: app.url + 'api_freight/show_freight',
			data: {
				order_id: options.order_id,
				id: options.id,
			},
			header: {
				'content-type': 'application/json',
				'token': wx.getStorageSync('token_key')
			}, success: function (json) {
				console.log(json.data.result)
				var address = [];
				if (json.data.result.freight !== false) {
					var address_all = json.data.result.freight.data;
					if (address_all != undefined) {
						for (var i = 0; i < 3; i++) {
							address.push(address_all[i]);
						}
					}
				}
				that.setData({
					address: address,
					data: json.data.result
				})
			}
		})

	},

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
	onReady: function () {

	},

  /**
   * 生命周期函数--监听页面显示
   */
	onShow: function () {

	},

  /**
   * 生命周期函数--监听页面隐藏
   */
	onHide: function () {

	},

  /**
   * 生命周期函数--监听页面卸载
   */
	onUnload: function () {

	},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
	onPullDownRefresh: function () {

	},

  /**
   * 页面上拉触底事件的处理函数
   */
	onReachBottom: function () {

	},

  /**
   * 用户点击右上角分享
   */
	onShareAppMessage: function () {

	}
})